<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" href="../res/layui/css/layui.css" media="all">
<script src="../res/layui/layui.js"></script>
</head>

<body>
	<form id='form_add' class="layui-form" action=""
		style="width: 60%; margin-top: 10px;" lay-filter="form_add">
		<div class="layui-form-item">
			<label class="layui-form-label">商品id</label>

			<div class="layui-input-block">
				<input type="text" name="pdtId" placeholder="" autocomplete="off"
				class="layui-input">
             </div>
		</div>
		
		
		<div class="layui-form-item">
			<label class="layui-form-label">商品数量</label>
			<div class="layui-input-block">
				<input type="text" name="carCount" placeholder="" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit lay-filter="add_submit">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>
</body>

<script>
	layui.use([ 'layer', 'form' ], function() {
		var $ = layui.$ //jquery
		, layer = layui.layer //弹层
		, form = layui.form //表单	

		//点击添加按钮
		form.on('submit(add_submit)', function(data) {
			var str = $("#form_add").serialize();
			$.post("http://localhost:8080/g4/carproduct/insertProduct", str,

			function(result) {
				if (result.code === '0') {
					//调用父页面的搜索按钮
					parent.layui.$("#search").click();
					//弹框提示信息
					parent.layer.alert(result.msg);
					//关闭自身
					var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					parent.layer.close(index); //再执行关闭  
				} else {
					layer.alert(result.msg);
				}
			}, "json");
			return false;
		});
	});
</script>

</html>